package com.starview.star.compiler.util;

import java.util.Iterator;
import java.util.NoSuchElementException;



public class SingleIterator<T> implements Iterator<T>
{
  private T value;

  public SingleIterator(T value)
  {
    this.value = value;
  }

  @Override
  public boolean hasNext()
  {
    return value!=null;
  }

  @Override
  public T next()
  {
    if(value!=null){
      T val = value;
      value = null;
      return val;
    }
    throw new NoSuchElementException();
  }

  @Override
  public void remove()
  {
    throw new UnsupportedOperationException();
  }
}
